<!-- 本月目标 -->
<template>
  <el-card :header="title"
           body-style="height:276px">
    <template v-slot:header>
      <span class="titleCard">用户统计</span>
    </template>
    <div>
      <!-- 四宫格 -->
      <div class="fourPalaceGrid">
        <div class="singlePalaceGrid">
          <div>
            <img class="icon"
                 src="../../../../assets/Group 2768.png"
                 alt="" />
          </div>
          <div class="accumulateNum">
            <vue-count-up class="Num"
                          :end-val="
                userStatisticsObject?.userTotal
                  ? userStatisticsObject?.userTotal
                  : '0'
              " />
            <div>用户数量(个)</div>
          </div>
        </div>
        <div class="singlePalaceGrid">
          <div>
            <img class="icon"
                 src="../../../../assets/Group 2766.png"
                 alt="" />
          </div>
          <div class="accumulateNum">
            <vue-count-up class="Num"
                          :options="countUpOptions"
                          :end-val="
               userStatisticsObject?.topUpTotalAmount
                  ? userStatisticsObject?.topUpTotalAmount
                  : '0'
              " />
            <div>累计充值(元)</div>
          </div>
        </div>
        <div class="singlePalaceGrid">
          <div>
            <img class="icon"
                 src="../../../../assets/Group 2766.png"
                 alt="" />
          </div>
          <div class="accumulateNum">
            <vue-count-up class="Num"
                          :options="countUpOptions"
                          :end-val="
                userStatisticsObject?.todayTopUpTotalAmount
                  ? userStatisticsObject?.todayTopUpTotalAmount
                  : '0'
              " />
            <div>今日充值(元)</div>
          </div>
        </div>

        <div class="singlePalaceGrid">
          <div>
            <img class="icon"
                 src="../../../../assets/Group 2764.png"
                 alt="" />
          </div>
          <div class="accumulateNum">
            <vue-count-up class="Num"
                          :options="countUpOptions"
                          :end-val="
                userStatisticsObject?.todayPlatformRevenue
                  ? userStatisticsObject?.todayPlatformRevenue
                  : '0'
              " />
            <div>今日收益(元)</div>
          </div>
        </div>
        <div class="singlePalaceGrid">
          <div>
            <img class="icon"
                 src="../../../../assets/Group 2984.png"
                 alt="" />
          </div>
          <div class="accumulateNum">
            <vue-count-up class="Num"
                          :options="countUpOptions"
                          :end-val="
               userStatisticsObject?.cumulativeConsumption
                  ? userStatisticsObject?.cumulativeConsumption
                  : '0'
              " />
            <div>累计消费(元)</div>
          </div>
        </div>
      </div>
      <div class="fourPalaceGrid">
        <div class="singlePalaceGrid">
          <div>
            <img class="icon"
                 src="../../../../assets/Group 2793.png"
                 alt="" />
          </div>
          <div class="accumulateNum">
            <vue-count-up class="Num"
                          :options="countUpOptions"
                          :end-val="
               userStatisticsObject?.todayConsumption
                  ? userStatisticsObject?.todayConsumption
                  : '0'
              " />
            <div>今日消费(元)</div>
          </div>
        </div>
        <div class="singlePalaceGrid">
          <div>
            <img class="icon"
                 src="../../../../assets/Group 2774.png"
                 alt="" />
          </div>
          <div class="accumulateNum">
            <vue-count-up class="Num"
                          :options="countUpOptions"
                          :end-val="
                userStatisticsObject?.totalWithdrawal
                  ? userStatisticsObject?.totalWithdrawal
                  : '0'
              " />
            <div>累计已提现(元)</div>
          </div>
        </div>
        <div class="singlePalaceGrid">
          <div>
            <img class="icon"
                 src="../../../../assets/Group 2791.png"
                 alt="" />
          </div>
          <div class="accumulateNum">
            <vue-count-up class="Num"
                          :options="countUpOptions"
                          :end-val="
                userStatisticsObject?.TodayWithdrawal
                  ? userStatisticsObject?.TodayWithdrawal
                  : '0'
              " />
            <div>今日已提现(元)</div>
          </div>
        </div>
        <div class="singlePalaceGrid">
          <div>
            <img class="icon"
                 src="../../../../assets/Group 2792.png"
                 alt="" />
          </div>
          <div class="accumulateNum">
            <vue-count-up class="Num"
                          :end-val="
                userStatisticsObject?.todayUser
                  ? userStatisticsObject?.todayUser
                  : '0'
              " />

            <div>今日新增用户(个)</div>
          </div>
        </div>
        <div class="singlePalaceGrid">
          <div>
            <img class="icon"
                 src="../../../../assets/Group 2764.png"
                 alt="" />
          </div>
          <div class="accumulateNum">
            <vue-count-up class="Num"
                          :options="countUpOptions"
                          :end-val="
                userStatisticsObject?.totalPlatformRevenue
                  ? userStatisticsObject?.totalPlatformRevenue
                  : '0'
              " />
            <div>累计收益(元)</div>
          </div>
        </div>
      </div>
    </div>
  </el-card>
</template>

<script>
import { userStatistics } from '@/api/financialManagement/index';
import VueCountUp from 'vue-countup-v2';
export default {
  //   const emit = defineEmits(['command']);
  name: 'statistics-card',
  props: {
    title: String
  },
  components: {
    VueCountUp
  },
  data () {
    return {
      userStatisticsObject: null,
      countUpOptions: {
        useEasing: true,
        useGrouping: true,
        separator: ',',
        decimal: '.',
        decimalPlaces: 2,
        prefix: '',
        suffix: ''
      },
    };
  },
  created () {
    this.userStatisticsFn();
  },
  methods: {
    async userStatisticsFn () {
      const res = await userStatistics({
        siteId: this.$store.state.site.info.id
      });
      console.log(res);
      this.userStatisticsObject = res;
    },
    onCommand (command) {
      console.log(command);
      emit('command', command);
    }
  }
};
</script>

<style lang="less" scoped>
.titleCard {
  &::before {
    content: url('../../../../static/svg/userStatistics.svg');
    display: inline-block;
    vertical-align: middle;
    margin-right: 2px;
    padding-left: 9px;
  }
}
.fourPalaceGrid {
  margin: 43px 0;
  display: flex;
  flex-wrap: wrap;
  .singlePalaceGrid {
    width: 20%;
    height: 93px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    padding-left: 28px;

    .accumulateNum {
      height: 62px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-evenly;
      .Num {
        color: #1e6ceb;
        font-size: 20px;
      }
    }
  }
  .icon {
    width: 32px;
    height: 32px;
  }
}

:deep(.el-card__body) {
  padding: 0;
}
.accumulatedSitesBg {
  background-image: url('/src/assets/images/Rectangle 2056.png');
  background-repeat: no-repeat;
  background-size: contain;
  height: 128px;
  width: 400px;

  .padding30 {
    padding: 17px 0 0 20px;
    .sitesNum {
      color: #fff;
      font-size: 30px;
      font-weight: 400;
    }
    .accumulatedSites {
      color: #fff;
    }
  }
}
.workplace-goal {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;

  .workplace-goal-body {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 180px;
    margin: -48px 0 0 -90px;
    text-align: center;
  }
}
</style>
